﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using KerriganInterface.IServiceClient;
using KerriganDataContract;
using KerriganService.DAC;
using KerriganDataContract.Person;
using KerriganDataContract.Session;
using KerriganDataContract.Code;
using KerriganDataContract.OfficialTest;
using KerriganDataContract.Authentification;
using KerriganDataContract.Customer;

namespace KerriganService.ServiceClient
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ClientService" in code, svc and config file together.
    public class ClientService : IClientService
    {

        public CustomerDC GetCustomer(int id)
        {
            try
            {
                return CustomerDAC.GetCustomer(id);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }

        public CustomerDC CheckLoginCustomer(string nickName, string password)
        {
            try
            {
                return AuthenticationDAC.CheckLoginCustomer(nickName, password);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }

        public List<SessionDC> GetSessionsByCustomerID(int customerID)
        {   
            try
            {
                return SessionCoursesDAC.GetSessionsByCustomer(customerID);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }

        public List<CodeDC> GetCodesByCustomerID(int customerID)
        {
            try
            {
                return CodeDAC.GetCodeByUser(customerID);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }

        public List<OfficialTestDC> GetExamsByCustomerID(int customerID)
        {
            try
            {
                return ExamDAC.GetCustomerExams(customerID);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }




        public bool AddSessionToUser(int idSession, int customerID)
        {
            try
            {
                return SessionCoursesDAC.AddCustomerToSession(idSession, customerID);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }


        List<SessionBycustomerLight_Result> IClientService.GetSessionsAvailableByCustomerID(int customerID)
        {
            try
            {
                return SessionCoursesDAC.GetAllSessionAgencyBycustomerAndOffer(customerID);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
    }
}
